import { SET_TGT_TOKEN, SET_USER_INFO, SET_USER_OPEN_ID,SET_TOKEN } from '../types'
import { Module } from 'vuex'
import { userToLoginType } from '../interface'

const state = {
  userInfo: null,
  openId: null,
  tgt:null,
  token:null
}

const mutations = {
  [SET_USER_INFO](state: Store.UserTypes, payload: AnyObject) {
    state.userInfo = payload
  },
  [SET_USER_OPEN_ID](state: Store.UserTypes, openId: string) {
    state.openId = openId
  },
  [SET_TGT_TOKEN](state: Store.UserTypes, tgt:string){
    state.tgt = tgt
  },
  [SET_TOKEN](state: Store.UserTypes, token:string){
    state.token = token
  }
}

const actions = {}

const store: Module<Store.UserTypes, Store.RootStateType> = {
  namespaced: true,
  state,
  mutations,
  actions,
}

export default store
